package com.geekaca.news.mapper;

import cn.hutool.core.util.PageUtil;
import com.geekaca.news.domain.News;
import com.geekaca.news.domain.NewsTag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author Peter
* @description 针对表【tb_news】的数据库操作Mapper
* @createDate 2024-02-16 16:44:13
* @Entity com.geekaca.news.domain.News
*/
@Mapper
public interface NewsMapper {

    List<News> selectNewsAndCategory();

//    List<News> blurSearchByTitleContent(@Param("news")News news);
    List<News> blurSearchByTitleContent(News news);

    int deleteByPrimaryKey(@Param("ids") List<Long> ids);

    int insert(News record);

    int insertSelective(News record);

    News selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(News record);

    int updateByPrimaryKey(News record);

    News selectNewsAndCommentById(@Param("newsId") Long id);


    Integer getTotalNews(PageUtil pageUtil);

    List<News> findNewsList(PageUtil pageUtil);

    int getAllNewsCount(@Param("keyword")String keyword);

    List<News> getAllNews(@Param("start")int start, @Param("pageSize")int pageSize, @Param("keyword") String keyword);

    List<News> getAllNewsByCategory(@Param("start")int start, @Param("pageSize")int pageSize,
                             @Param("category") String category);


    int increateViews(@Param("newsId") Long newsId );

    List<News> selectAllNewsByTagId(@Param("tagId") Integer tagId, @Param("start") Integer start,
                                    @Param("pageSize") Integer pageSize);

    int selectCountByTagId(@Param("tagId") Integer tagId);

    List<NewsTag> getHotTags();

    List<News> getHotNews();

    List<News> getRecentNews();

    int getNewsCountByCate(@Param("category") String keyword);

    int getNewsTagIdCount(                          @Param("tagId") Integer tagId);
}
